//
//  CompetionBackDetailController.m
//  ShangHaiTuJI

//

//  Created by xiaoxiangtuji on 2017/9/22.
//  Copyright © 2017年 xiaoxiangtuji. All rights reserved.
//

#import "CompetionBackDetailController.h"
#import "MusicManager.h"
#import "photoListCell.h"
#import "QQAndWechatShareView.h"
#import "WXApi.h"
#import "AppDelegate.h"
@interface CompetionBackDetailController ()<UISearchControllerDelegate,UISearchResultsUpdating,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,UICollectionViewDataSource,UIWebViewDelegate>{
    AppDelegate *appdelegate;
}

@property(nonatomic,strong)UIScrollView *scrollView;
@property(nonatomic,strong)UISearchController *searchController;
@property(nonatomic,strong)UIImageView *bgImageView;
@property(nonatomic,strong)UIScrollView *middleScroll;
@property(nonatomic,strong)UIButton *musicBtn;
@property(nonatomic,strong)NSTimer *timer;
@property(nonatomic,strong)UICollectionView *collectionView;
@property(nonatomic,strong)UICollectionViewFlowLayout *flowLayout;
@property(nonatomic,strong)QQAndWechatShareView *shareView;
@property(nonatomic,strong)UIWebView *webVeiw;
@end

@implementation CompetionBackDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"赛事回顾";
     [self createShareBtn];
    [self loadWebViewData];
//    [self reloadDataWithIndex:0];
//    self.timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(timerAc) userInfo:nil repeats:YES];
//    [self createSearchbarController];
//    [self setMyScrollview];
    // Do any additional setup after loading the view.
}
-(void)loadWebViewData{
    self.webVeiw = [[UIWebView alloc] initWithFrame:CGRectMake(0, 64, WIDTH, HEIGHT- 64)];
    [self.view addSubview:self.webVeiw];
//    NSString *path1 = [[NSBundle mainBundle]pathForResource:@"1、服务条款的确认和接纳" ofType:@"doc"];
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/h5/review?id=%@",ServerIp,self.matchId]];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [self.webVeiw loadRequest:request];
    _webVeiw.scalesPageToFit = YES;
}
- (void)timerAc{
    if ([MusicManager shareInfo].player.currentTime.timescale == 0 || [MusicManager shareInfo].player.currentItem.duration.timescale == 0) {
        [[MusicManager shareInfo] replaceItemWithUrlString:@"http://audio.xmcdn.com/group2/M02/1D/F7/wKgDr1HACYrCN1vvACKR7bboVQo092.mp3"];
        NSLog(@"结束了歌曲");
//        return;
    }
    if ([MusicManager shareInfo].isPlay) {
        [UIView beginAnimations:@"rzoration" context:nil];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
        self.musicBtn.transform = CGAffineTransformRotate(self.musicBtn.transform, 0.02);
        [UIView commitAnimations];
    }
}
- (void)reloadDataWithIndex:(NSInteger)index
{
    NSString *musicStr = @"http://audio.xmcdn.com/group2/M02/1D/F7/wKgDr1HACYrCN1vvACKR7bboVQo092.mp3";
    // 修改播放歌曲
    [[MusicManager shareInfo] replaceItemWithUrlString:musicStr];
}
/**
 布局scrollview
*/
-(void)setMyScrollview{
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 64, WIDTH, HEIGHT - 64)];
    [self.view addSubview:self.scrollView];
    self.scrollView.showsVerticalScrollIndicator = NO;
    self.scrollView.contentSize = CGSizeMake(WIDTH, scaleTopAndBottom(840));
    self.bgImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WIDTH,scaleTopAndBottom(840))];
    [self.scrollView addSubview:self.bgImageView];
    self.bgImageView.image = [UIImage imageNamed:@"cometionBackBgView.jpg"];
    self.bgImageView.userInteractionEnabled = YES;
    UILabel *titleLabel = [[UILabel alloc] init];
    titleLabel.text = @"活动主题";
    titleLabel.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:16];
    titleLabel.font = [UIFont systemFontOfSize:16];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    [self.bgImageView addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.bgImageView.mas_centerX);
        make.top.equalTo(self.bgImageView.mas_top).offset(scaleTopAndBottom(25));
        make.size.mas_equalTo(CGSizeMake(WIDTH - 200, scaleTopAndBottom(20)));
    }];
    
    self.musicBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.musicBtn setBackgroundImage:[UIImage imageNamed:@"MusicTransfrom"] forState:UIControlStateNormal];
    [self.musicBtn addTarget:self action:@selector(playOrPauseMusic:) forControlEvents:UIControlEventTouchUpInside];
    [self.bgImageView addSubview:self.musicBtn];
    [self.musicBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.bgImageView.mas_top).offset(scaleTopAndBottom(10));
        make.right.equalTo(self.bgImageView.mas_right).offset(-10);
        make.size.mas_equalTo(CGSizeMake(32, 32));
    }];
    
    UILabel *engtitleLabel = [[UILabel alloc] init];
    engtitleLabel.textAlignment = NSTextAlignmentCenter;
    engtitleLabel.text = @"ACTIVITY THEME";
    engtitleLabel.font = [UIFont systemFontOfSize:10];
    engtitleLabel.textColor = COLOR_HEX(0x666666);
    [self.bgImageView addSubview:engtitleLabel];
    [engtitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.bgImageView.mas_centerX);
        make.top.equalTo(titleLabel.mas_bottom).offset(scaleTopAndBottom(5));
        make.size.mas_equalTo(CGSizeMake(WIDTH, scaleTopAndBottom(20)));
    }];
    UILabel *topicLabel = [[UILabel alloc] init];
    topicLabel.textAlignment = NSTextAlignmentCenter;
    topicLabel.text = @"我的街巷,我的家带你找回童年的那些事儿";
    topicLabel.font = [UIFont systemFontOfSize:14];
    [self.bgImageView addSubview:topicLabel];
    [topicLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.bgImageView.mas_centerX);
        make.top.equalTo(engtitleLabel.mas_bottom).offset(scaleTopAndBottom(15));
        make.size.mas_equalTo(CGSizeMake(WIDTH, scaleTopAndBottom(20)));
    }];
    
    UIImageView *leftImageView = [[UIImageView alloc] init];
    leftImageView.image = [UIImage imageNamed:@"xiangkuangfangxiang"];
    [self.bgImageView addSubview:leftImageView];
    [leftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_bgImageView.mas_left).offset(23);
        make.top.equalTo(self.bgImageView.mas_top).offset(scaleTopAndBottom(254));
        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(21), scaleTopAndBottom(42)));
    }];
    leftImageView.transform = CGAffineTransformMakeRotation(M_PI);
    UIImageView *rightImageView = [[UIImageView alloc] init];
    rightImageView.image = [UIImage imageNamed:@"xiangkuangfangxiang"];
    [self.bgImageView addSubview:rightImageView];
    [rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(_bgImageView.mas_right).offset(-23);
        make.top.equalTo(self.bgImageView.mas_top).offset(scaleTopAndBottom(254));
        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(21), scaleTopAndBottom(42)));
    }];
    
    self.flowLayout = [[UICollectionViewFlowLayout alloc] init];
    self.flowLayout.minimumLineSpacing = 0.0f;
    self.flowLayout.minimumInteritemSpacing = 0.0f;
    self.flowLayout.itemSize = CGSizeMake(scaleLeftAndRight(265), scaleTopAndBottom(316));
    self.flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:self.flowLayout];
    self.collectionView.pagingEnabled = YES;
    self.collectionView.showsHorizontalScrollIndicator = NO;
    self.collectionView.backgroundColor = [UIColor clearColor];
    self.collectionView.dataSource = self;
    self.collectionView.delegate = self;
    [self.collectionView registerClass:[photoListCell class] forCellWithReuseIdentifier:@"photoListCell"];
    [self.bgImageView addSubview:self.collectionView];
    [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(topicLabel.mas_bottom).offset(scaleTopAndBottom(49));
        make.left.equalTo(leftImageView.mas_right).offset(25);
        make.height.mas_equalTo(scaleTopAndBottom(320));
        make.width.mas_equalTo(scaleLeftAndRight(265));
    }];
    
    UIImageView *iconImageView = [[UIImageView alloc] init];
    iconImageView.backgroundColor = [UIColor cyanColor];
    [self.bgImageView addSubview:iconImageView];
    [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bgImageView.mas_left).offset(76);
        make.top.equalTo(topicLabel.mas_bottom).offset(scaleTopAndBottom(380));
        make.size.mas_equalTo(CGSizeMake(35, 35));
    }];
    iconImageView.layer.cornerRadius = 17.5;
    iconImageView.layer.masksToBounds = YES;
    UIButton *priseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    CGSize imageSize = priseBtn.imageView.bounds.size;
    CGFloat interval = 5.0f;
    priseBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -imageSize.width - interval, 0, imageSize.width + interval);
    [priseBtn setTitle:@" 1000" forState:UIControlStateNormal];
    [priseBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [priseBtn setImage:[UIImage imageNamed:@"admm"] forState:UIControlStateNormal];
    [self.bgImageView addSubview:priseBtn];
    [priseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.bgImageView.mas_right).offset(-26);
        make.top.equalTo(topicLabel.mas_bottom).offset(scaleTopAndBottom(380));
        make.size.mas_equalTo(CGSizeMake(100, 30));
    }];
    UILabel *worksLabel = [[UILabel alloc] init];
    worksLabel.text = @"《带你找回爱》";
    worksLabel.textColor = COLOR_HEX(0x454545);
    worksLabel.font = [UIFont systemFontOfSize:14];
    [self.bgImageView addSubview:worksLabel];
    [worksLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(iconImageView.mas_right).offset(2); make.top.equalTo(topicLabel.mas_bottom).offset(scaleTopAndBottom(375));
        make.height.mas_equalTo(scaleTopAndBottom(20));
        make.right.equalTo(priseBtn.mas_left).offset(-43);
    }];
    UILabel *authorLabel = [[UILabel alloc] init];
    authorLabel.text = @"作者:陈一发er";
    authorLabel.textColor = COLOR_HEX(0x626262);
    authorLabel.font = [UIFont systemFontOfSize:12];
    [self.bgImageView addSubview:authorLabel];
    [authorLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(iconImageView.mas_right).offset(6);
        make.top.equalTo(worksLabel.mas_bottom).offset(7);
         make.right.equalTo(priseBtn.mas_left).offset(-43);
        make.height.mas_equalTo(scaleTopAndBottom(12));
    }];
    UILabel *introduceLabel = [[UILabel alloc] init];
    introduceLabel.backgroundColor = [UIColor orangeColor];
    [self.bgImageView addSubview:introduceLabel];
    [introduceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(authorLabel.mas_bottom).offset(scaleTopAndBottom(50));
        make.centerX.equalTo(self.bgImageView.mas_centerX);
        make.size.mas_equalTo(CGSizeMake(568/2, 152/2));
    }];
    UIImageView *appImageView = [[UIImageView alloc] init];
    appImageView.image = [UIImage imageNamed:@"图层9"];
    [self.bgImageView addSubview:appImageView];
    [appImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bgImageView.mas_left).offset(60);
        make.top.equalTo(introduceLabel.mas_bottom).offset(scaleTopAndBottom(45));
            make.size.mas_equalTo(CGSizeMake(55, 55));
    }];
    appImageView.layer.cornerRadius = 27.5;
    appImageView.layer.masksToBounds = YES;
    UIImageView *codeImageView = [[UIImageView alloc] init];
    [self.bgImageView addSubview:codeImageView];
    [codeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.bgImageView.mas_right).offset(-60);
        make.top.equalTo(introduceLabel.mas_bottom).offset(scaleTopAndBottom(45));
        make.size.mas_equalTo(CGSizeMake(55, 55));
    }];
    codeImageView.image = [UIImage imageNamed:@"图层10"];
    UILabel *downLabel = [[UILabel alloc] init];
    downLabel.text = @"下载途吉APP";
    downLabel.font = [UIFont systemFontOfSize:14];
    downLabel.textColor = COLOR_HEX(0x333333);
//    downLabel.font = [UIFont systemFontOfSize:<#(CGFloat)#>]
    [self.bgImageView addSubview:downLabel];
    [downLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(introduceLabel.mas_bottom).offset(scaleTopAndBottom(50));
        make.left.equalTo(appImageView.mas_right).offset(8);
        make.right.equalTo(codeImageView.mas_left).offset(-8);
        make.height.mas_equalTo(scaleTopAndBottom(20));
    }];
    UILabel *moreLabel = [[UILabel alloc] init];
//    moreLabel.backgroundColor = [UIColor orangeColor];
    moreLabel.text = @"更多精彩活动等着你哦";
    moreLabel.font = [UIFont systemFontOfSize:12];
    moreLabel.textColor = COLOR_HEX(0x666666);
    [self.bgImageView addSubview:moreLabel];
    [moreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(downLabel.mas_bottom).offset(scaleTopAndBottom(5));
        make.left.equalTo(appImageView.mas_right).offset(8);
        make.right.equalTo(codeImageView.mas_left).offset(-8);
        make.height.mas_equalTo(scaleTopAndBottom(20));
    }];
    UIView *bottomView = [[UIView alloc] init];
    bottomView.backgroundColor = [UIColor whiteColor];
    bottomView.alpha = 0.5;
    [self.bgImageView addSubview:bottomView];
    [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.bgImageView.mas_centerX);
        make.left.equalTo(self.bgImageView.mas_left).offset(scaleLeftAndRight(111));
        make.height.mas_equalTo(scaleTopAndBottom(25));
        make.top.equalTo(moreLabel.mas_bottom).offset(scaleTopAndBottom(56));
    }];
    bottomView.layer.cornerRadius = 12.5;
    bottomView.layer.masksToBounds = YES;
    UIImageView *symbolImageView = [[UIImageView alloc] init];
    symbolImageView.image = [UIImage imageNamed:@"图层4"];
    [bottomView addSubview:symbolImageView];
    [symbolImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bottomView.mas_left).offset(20);
        make.centerY.equalTo(bottomView.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(20, 20));
    }];
    UILabel *inistiLable = [[UILabel alloc] init];
    inistiLable.text = @"上海城市规划馆";
    [bottomView addSubview:inistiLable];
    [inistiLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(symbolImageView.mas_right).offset(5);
        make.right.equalTo(bottomView.mas_right).offset(-20);
        make.centerY.equalTo(bottomView.mas_centerY);
        make.height.mas_equalTo(20);
    }];
}
-(void)playOrPauseMusic:(UIButton *)btn{
    if ([MusicManager shareInfo].isPlay == YES) {
        [btn.layer removeAllAnimations];
        
    }else{
        
    }
    [[MusicManager shareInfo] playAndPause];
}
/**
 创建搜索框
 */
-(void)createSearchbarController{
//    self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
//    self.searchController.delegate = self;
//    self.searchController.searchResultsUpdater = self;
//    //    _searchController.dimsBackgroundDuringPresentation = NO;
//    self.searchController.obscuresBackgroundDuringPresentation = YES;
//    self.searchController.hidesNavigationBarDuringPresentation = NO;
//    self.searchController.searchBar.placeholder = @"搜索作者/作品名称";
//    self.searchController.searchBar.barStyle = UIBarStyleBlack;
//    [self.searchController.searchBar setValue:@"取消" forKeyPath:@"_cancelButtonText"];
//    UITextField *searchField = [_searchController.searchBar valueForKey:@"_searchField"];
//    [searchField setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
//    [self.searchController.searchBar setImage:[UIImage imageNamed:@"sousuo"] forSearchBarIcon:UISearchBarIconSearch state:UIControlStateNormal];
//    self.searchController.searchBar.frame = CGRectMake(0, 0, scaleLeftAndRight(220), 30);
//    self.navigationItem.titleView = self.searchController.searchBar;
    
}
-(void)createShareBtn{
    UIButton *shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    shareBtn.frame = CGRectMake(-20, 0, 30, 3);
    
    CGSize titleSize = shareBtn.titleLabel.bounds.size;
    CGSize imageSize = shareBtn.imageView.bounds.size;
    
    CGFloat interval = 10.0;
    shareBtn.imageEdgeInsets = UIEdgeInsetsMake(0,titleSize.width + interval, 0, -(titleSize.width + interval));
    shareBtn.titleEdgeInsets = UIEdgeInsetsMake(0, -(imageSize.width + interval), 0, imageSize.width + interval);
    [shareBtn setImage:[UIImage imageNamed:@"椭圆4"] forState:UIControlStateNormal];
    [shareBtn addTarget:self action:@selector(showShareUI) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *rightBar = [[UIBarButtonItem alloc] initWithCustomView:shareBtn];
    UIBarButtonItem *flexSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:self action:nil];
    flexSpacer.width = -10;
    self.navigationItem.rightBarButtonItems = @[flexSpacer,rightBar];
}
#pragma mark -UIserachController的执行过程
-(void)willPresentSearchController:(UISearchController *)searchController{
    NSLog(@"搜索框将要出现");
}
-(void)didPresentSearchController:(UISearchController *)searchController{
    NSLog(@"搜索框已经出现");
}
-(void)willDismissSearchController:(UISearchController *)searchController{
    NSLog(@"搜索框将要消失");
}
-(void)didDismissSearchController:(UISearchController *)searchController{
    NSLog(@"搜索框已经消失");
}

-(void)presentSearchController:(UISearchController *)searchController{
    NSLog(@"出现了");
}
-(void)updateSearchResultsForSearchController:(UISearchController *)searchController{
    

    
}



-(void)createCollectionViewUI{

}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 10;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    photoListCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"photoListCell" forIndexPath:indexPath];
    return cell;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"%ld",(long)indexPath.row);
}
-(void)viewDidDisappear:(BOOL)animated{
    [[MusicManager shareInfo].player pause];
    [MusicManager shareInfo].player = nil;
    [self.timer invalidate];
    self.timer = nil;
}
-(void)showShareUI{
    UIView *backView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    backView.alpha = 0.5f;
    backView.backgroundColor = [UIColor blackColor];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removebackView:)];
    [backView addGestureRecognizer:tap];
    [[UIApplication sharedApplication].keyWindow addSubview:backView];
    _shareView = [[QQAndWechatShareView alloc] initWithFrame:CGRectMake(0, HEIGHT, WIDTH, scaleTopAndBottom(94))];
    [_shareView.QQBtn addTarget:self action:@selector(QQShare:) forControlEvents:UIControlEventTouchUpInside];
    [_shareView.WechatBtn addTarget:self action:@selector(WechatShare:) forControlEvents:UIControlEventTouchUpInside];
    [[UIApplication sharedApplication].keyWindow addSubview:_shareView];
    [UIView animateWithDuration:0.1 animations:^{
        _shareView.frame = CGRectMake(0,HEIGHT - scaleTopAndBottom(94), WIDTH, scaleTopAndBottom(94));
    }];
}
-(void)WechatShare:(UIButton *)btn{
    /** 标题
     * @note 长度不能超过512字节
     */
    // @property (nonatomic, retain) NSString *title;
    /** 描述内容
     * @note 长度不能超过1K
     */
    //@property (nonatomic, retain) NSString *description;
    /** 缩略图数据
     * @note 大小不能超过32K
     */
    //  @property (nonatomic, retain) NSData   *thumbData;
    /**
     * @note 长度不能超过64字节
     */
    // @property (nonatomic, retain) NSString *mediaTagName;
    /**
     * 多媒体数据对象，可以为WXImageObject，WXMusicObject，WXVideoObject，WXWebpageObject等。
     */
    // @property (nonatomic, retain) id        mediaObject;
    
    /*! @brief 设置消息缩略图的方法
     *
     * @param image 缩略图
     * @note 大小不能超过32K
     */
    //- (void) setThumbImage:(UIImage *)image;
    //缩略图
    UIImage *image = [UIImage imageNamed:@"LOGO4"];
    WXMediaMessage *message = [WXMediaMessage message];
    message.title = @"拼才艺，发现自己，展现自我";
    message.description = @"加入趣味赛事，增长经验值，让孩子在参与中获得自信与快乐";
    //png图片压缩成data的方法，如果是jpg就要用 UIImageJPEGRepresentation
    message.thumbData = UIImagePNGRepresentation(image);
    [message setThumbImage:image];
    
    
    WXWebpageObject *ext = [WXWebpageObject object];
    ext.webpageUrl = [NSString stringWithFormat:@"%@/h5/review?id=%@",ServerIp,self.matchId];
    message.mediaObject = ext;
    message.mediaTagName = @"ISOFTEN_TAG_JUMP_SHOWRANK";
    
    SendMessageToWXReq *sentMsg = [[SendMessageToWXReq alloc]init];
    sentMsg.message = message;
    sentMsg.bText = NO;
    sentMsg.scene =  WXSceneSession;
    //    //选择发送到会话(WXSceneSession)或者朋友圈(WXSceneTimeline)
    //    if (isPengyouquan) {
    //        sentMsg.scene = WXSceneTimeline;  //分享到朋友圈
    //    }else{
    //        sentMsg.scene =  WXSceneSession;  //分享到会话。
    //    }
    
    //如果我们想要监听是否成功分享，我们就要去appdelegate里面 找到他的回调方法
    // -(void) onResp:(BaseResp*)resp .我们可以自定义一个代理方法，然后把分享的结果返回回来。
    appdelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
    //添加对appdelgate的微信分享的代理
    //    appdelegate.wxDelegate = self;
    BOOL isSuccess = [WXApi sendReq:sentMsg];
}
-(void)QQShare:(UIButton *)btn{
    //创建分享消息对象
    UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
    
    //创建网页内容对象
    NSString* thumbURL =  @"http://www.tj698.com/resource/img/logo.png";
    UMShareWebpageObject *shareObject = [UMShareWebpageObject shareObjectWithTitle:@"拼才艺，发现自己，展现自我" descr:@"加入趣味赛事，增长经验值，让孩子在参与中获得自信与快乐" thumImage:thumbURL];
    //设置网页地址
    shareObject.webpageUrl = [NSString stringWithFormat:@"%@/h5/review?id=%@",ServerIp,self.matchId];
    
    //分享消息对象设置分享内容对象
    messageObject.shareObject = shareObject;
    
    //调用分享接口
    [[UMSocialManager defaultManager] shareToPlatform:UMSocialPlatformType_QQ messageObject:messageObject currentViewController:self completion:^(id data, NSError *error) {
        if (error) {
            UMSocialLogInfo(@"************Share fail with error %@*********",error);
        }else{
            if ([data isKindOfClass:[UMSocialShareResponse class]]) {
                UMSocialShareResponse *resp = data;
                //分享结果消息
                UMSocialLogInfo(@"response message is %@",resp.message);
                //第三方原始返回的数据
                UMSocialLogInfo(@"response originalResponse data is %@",resp.originalResponse);
                
            }else{
                UMSocialLogInfo(@"response data is %@",data);
            }
        }
        //        [self alertWithError:error];
    }];
    
}
-(void)removebackView:(UITapGestureRecognizer *)tap{
    
    [UIView animateWithDuration:0.1 animations:^{
        UIView *view = tap.view;
        [view removeFromSuperview];
        [_shareView removeFromSuperview];
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
